package com.css.fxfzysx.modules.lifeline.repository.impl;

import com.css.fxfzysx.modules.lifeline.entity.newEntity.SmxBaseStationEntity;
import com.css.fxfzysx.modules.lifeline.entity.newEntity.SmxGasStoreEntity;
import com.css.fxfzysx.modules.lifeline.entity.newEntity.SmxPowerhouseEntity;
import com.css.fxfzysx.modules.lifeline.entity.newEntity.SmxWaterRoomEntity;
import com.css.fxfzysx.modules.lifeline.repository.HubBuildingRepository;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

@Repository
public class HubBuildingRepositoryImpl implements HubBuildingRepository {

    @Resource
    private JdbcTemplate jdbcTemplate;

    @Override
    public void saveWpRoom(SmxWaterRoomEntity entity) {
        jdbcTemplate.update("insert into czt_smx_water_room  (id,num_type,waterworks_name,structure_type,longitude,latitude,building_name,brick_masonry_label,liquefaction6,liquefaction7,liquefaction8,liquefaction9,seismic_subsidence6,seismic_subsidence7,seismic_subsidence8,seismic_subsidence9,del_flag,version_id,table_id,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,create_user,create_time,geom )" +
                " values ('"+entity.getId()+"', '"+entity.getNumType()+"', '"+entity.getWaterworksName()+"', '"+entity.getStructureType()+"', '"+entity.getLongitude()+"', '"+entity.getLatitude()+"', '"+entity.getBuildingName()+"', '"+entity.getBrickMasonryLabel()+"', '"+entity.getLiquefaction6()+"', '"+entity.getLiquefaction7()+"', '"+entity.getLiquefaction8()+"', '"+entity.getLiquefaction9()+"', '"+entity.getSeismicSubsidence6()+"', '"+entity.getSeismicSubsidence7()+"', '"+entity.getSeismicSubsidence8()+"', '"+entity.getSeismicSubsidence9()+"', '"+entity.getDelFlag()+"', '"+entity.getVersionId()+"', '"+entity.getTableId()+"', '"+entity.getDisasterRate6State()+"', '"+entity.getDisasterRate7State()+"', '"+entity.getDisasterRate8State()+"', '"+entity.getDisasterRate9State()+"', '"+entity.getDisasterRate10State()+"', '"+entity.getCreateUser()+"', '"+entity.getCreateTime()+"',st_geomfromtext('POINT('||"+entity.getLongitude()+"||' '|| "+entity.getLatitude()+"||')',4490))");
    }

    @Override
    public void savePowerhouse(SmxPowerhouseEntity entity) {
        jdbcTemplate.update("insert into czt_smx_powerhouse  (id,num_type,name,structure_type,position,longitude,latitude,installed_capacity,power_generation_type,construction,substation_construction,ep_construction,area,unit_price,version_id,table_id,del_flag,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,create_user,create_time,geom ) " +
                "values ('"+entity.getId()+"', '"+entity.getNumType()+"', '"+entity.getName()+"', '"+entity.getStructureType()+"', '"+entity.getPosition()+"', '"+entity.getLongitude()+"', '"+entity.getLatitude()+"', '"+entity.getInstalledCapacity()+"', '"+entity.getPowerGenerationType()+"', '"+entity.getConstruction()+"', '"+entity.getSubstationConstruction()+"', '"+entity.getEpConstruction()+"', '"+entity.getArea()+"', '"+entity.getUnitPrice()+"', '"+entity.getVersionId()+"', '"+entity.getTableId()+"', '"+entity.getDelFlag()+"', '"+entity.getDisasterRate6State()+"', '"+entity.getDisasterRate7State()+"', '"+entity.getDisasterRate8State()+"', '"+entity.getDisasterRate9State()+"', '"+entity.getDisasterRate10State()+"', '"+entity.getCreateUser()+"', '"+entity.getCreateTime()+"',st_geomfromtext('POINT('||"+entity.getLongitude()+"||' '|| "+entity.getLatitude()+"||')',4490))");
    }

    @Override
    public void saveGasStore(SmxGasStoreEntity entity) {
        jdbcTemplate.update("insert into czt_smx_gas_store  (id,num_type,name,structure_type,version_id,table_id,del_flag,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,longitude,latitude,create_user,create_time,geom) " +
                "values ('"+entity.getId()+"', '"+entity.getNumType()+"', '"+entity.getName()+"', '"+entity.getStructureType()+"', '"+entity.getVersionId()+"', '"+entity.getTableId()+"', '"+entity.getDelFlag()+"', '"+entity.getDisasterRate6State()+"','"+entity.getDisasterRate7State()+"', '"+entity.getDisasterRate8State()+"', '"+entity.getDisasterRate9State()+"', '"+entity.getDisasterRate10State()+"','"+entity.getLongitude()+"','"+entity.getLatitude()+"', '"+entity.getCreateUser()+"', '"+entity.getCreateTime()+"',st_geomfromtext('POINT('||"+entity.getLongitude()+"||' '|| "+entity.getLatitude()+"||')',4490))");
    }

    @Override
    public void saveBaseStation(SmxBaseStationEntity entity) {
        jdbcTemplate.update("insert into czt_smx_base_station  (id,code,num_type,name,structure_type,version_id,table_id,del_flag,disaster_rate6_state,disaster_rate7_state,disaster_rate8_state,disaster_rate9_state,disaster_rate10_state,longitude,latitude,create_user,create_time,geom ) " +
                "values ('" + entity.getId() + "','" + entity.getCode() + "', '" + entity.getNumType() + "', '" + entity.getName() + "', '" + entity.getStructureType() + "', '" + entity.getVersionId() + "', '" + entity.getTableId() + "', '" + entity.getDelFlag() + "', '" + entity.getDisasterRate6State() + "', '" + entity.getDisasterRate7State() + "', '" + entity.getDisasterRate8State() + "', '" + entity.getDisasterRate9State() + "', '" + entity.getDisasterRate10State() + "','" + entity.getLongitude() + "','" + entity.getLatitude()+ "','" + entity.getCreateUser()+ "','" + entity.getCreateTime() + "',st_geomfromtext('POINT('||" + entity.getLongitude() + "||' '|| " + entity.getLatitude() + "||')',4490))");
    }
}
